// Copyright 2011 Jefferson Willian
// willmont7@gmail.com

#include <cstdio>

#define MAX 10000

/* Longest subsequence sum algorithm */
void printResult(int saldo[], int n) {
  int buffer = 0;
  int init = 0;
  int temp_init = 0;
  int final = 0;
  int higher = 0;


  for (int i = 0;i < n;i++) {
    buffer += saldo[i];
    if (buffer < 0) {
      buffer = 0;
      temp_init = i+1;
    } else if (buffer >= higher) {
      init = temp_init;
      higher = buffer;
      final = i;
    }
  }

  printf("%d %d\n\n", init+1, final+1);
}

int main() {
  int n;
  int saldo[MAX];
  int in[2];
  int ok;
  int games = 1;

  while (scanf("%d", &n) && n != 0) {
    ok = false;

    for (int i = 0;i < n;i++) {
      scanf("%d%d", &in[0], &in[1]);
      saldo[i] = in[0]-in[1];
      if (saldo[i] > 0)
        ok = true;
    }

    printf("Teste %d\n", games++);

    if (!ok)
      printf("nenhum\n\n");
    else
      printResult(saldo, n);
  }

  return 0;
}
